﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using D3DSS.IDomain;
using D3DSS.DataContract;

namespace D3DSS.Service
{
    /// <summary>
    /// 账户服务
    /// </summary>
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class AccountService
    {
        protected IAccount Account { get; set; }

        public AccountService(IAccount account)
        {
            Account = account;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [WebInvoke(UriTemplate = "Register", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public Response<RegisterResponse> Register(RegisterRequest request)
        {
            return Account.Register(request);
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [WebInvoke(UriTemplate = "Login", ResponseFormat = WebMessageFormat.Json)]
        public Response<LoginResponse> Login(LoginRequest request)
        {
            return Account.Login(request);
        }
    }
}
